import {removeToken} from "@/utils/auth";
import Config from "@/settings";
import router from "@/router";
import request from "@/utils/request";

export function login(username, password, code, uuid) {
  return request({
    url: 'auth/login',
    method: 'post',
    data: {
      username,
      password,
      code,
      uuid
    }
  })
}

export function getInfo() {
  return request({
    url: 'auth/info',
    method: 'get'
  })
}

export function getCodeImg() {
  return request({
    url: 'auth/code',
    method: 'get'
  })
}

export function logout() {
  // return service({
  //   url: 'auth/logout',
  //   method: 'delete'
  // })
  request.delete('http://localhost:8000/auth/logout').then(res=>{
    removeToken(Config.TokenKey)
    router.replace('/login').then(r => {})
  })
}
